package com.shenhaofeng.app.http.okhttp;

import com.shenhaofeng.app.http.Creator;
import com.shenhaofeng.app.http.HttpClient;
import com.shenhaofeng.app.http.RealCall;
import com.shenhaofeng.app.http.adapter.Adapter;
import com.shenhaofeng.app.http.request.Request;

import okhttp3.OkHttpClient;


/**
 * Created by Administrator on 2016/5/5.
 */
public class OkHttpCreator implements Creator {

    private OkHttpClient okHttpClient;

    private Adapter adapter;


    public OkHttpCreator() {
        okHttpClient = new OkHttpClient();
    }


    public OkHttpCreator(OkHttpClient okHttpClient) {
        this.okHttpClient = okHttpClient;
    }


    public OkHttpClient getOkHttpClient() {
        return okHttpClient;
    }


    @Override
    public RealCall call(HttpClient httpClient, Request request) {
        return new OkCall(this, httpClient, request);
    }


    public OkHttpCreator adapter(Adapter adapter) {
        this.adapter = adapter;
        return this;
    }


    @Override
    public Adapter adapter() {
        return adapter;
    }


}
